﻿using BaseUtils.Utils;
using Service.src.NW.Model;
using System.Runtime.InteropServices;

namespace Service.src.Flow.Api
{

    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class UserPageApi
    {

        /// <summary>
        /// 保存页面组件数据
        /// </summary>
        /// <param name="ComponentJson"></param>
        /// <returns></returns>
        public string SaveUserPageComponent(int ProjectId, string Type, string ComponentJson)
        {
            if (ProjectId > 0)
            {
                FileHelper.WriteContent($"{AppData.RuntimeFlowDataViewDirectory}//{ProjectId}//",
                    AppData.UserPage + Type, ComponentJson);
            }

            return ComponentJson;
        }

        /// <summary>
        /// 查看页面
        /// </summary>
        /// <param name="ComponentJson"></param>
        /// <returns></returns>
        public string GetUserPageComponent(string Type)
        {
            string ComponentJson = FileHelper.ReadContent($"{AppData.RuntimeFlowDataViewDirectory + AppData.UserPage + Type}");
            return ComponentJson;
        }
    }
}
